<?php
namespace Admin\Controller;
use Think\Controller;
use Think\Model;
class ExtensionController extends IndexController {

    public function lists(){
        $this->display();
    }


    public function get_lists(){
        $test=D("Test");
        if(I("request.iDisplayStart")==''){
            $start=0;
        }else{
            $start=I("request.iDisplayStart");
        }
        if(I("request.sSearch")!=''){
            $where = 'like %'.I("request.sSearch").'%';
        }else{
            $where='';
        }
        $res= $test->table('tb_test a,tb_user b')
            ->where("a.ips=b.register_ip")
            ->distinct(true)
            ->field("a.ips,a.qrcode,b.register_time,b.telephone")
            ->limit($start,I("request.iDisplayLength"))
            ->select();
        $test1=$test->table('tb_test a,tb_user b')
            ->where("a.ips=b.register_ip")
            ->distinct(true)
            ->field("a.ips,a.qrcode,b.register_time,b.telephone")
            ->select();
        $count=count($test1);
        if(!$res){
            echo json_encode(0);exit;
        }
        
        
        foreach($res as &$v){
            $v['register_time']=date('Y-m-d H:i:s',$v['register_time']);
        }
        $ret = array(
            "sEcho" => intval($_GET['sEcho']),
            "iTotalRecords" => $start,
            "iTotalDisplayRecords" => $count,
            "aaData" => $res
        );

        echo json_encode($ret);exit;
    }
    

}